package com.hyjx.framework.component.operatelog.operatelogdetail;

import com.hyjx.framework.common.CommonUtil;
import com.hyjx.framework.orm.dao.IBaseDao;
import com.hyjx.framework.orm.dao.Pager;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 操作日志详细实现类
 */
@Service
public class OperatelogDetailServiceImpl implements OperatelogDetailService {

    @Resource
    private IBaseDao dao;

    @Override
    public String queryList(OperatelogDetailModel model) {
        Pager pager = dao.getPager(model.getModuleName() + ".queryList", model.getModuleName() + ".queryCount", model);
        return CommonUtil.getPageJsonStr(pager);
    }

    @Override
    public boolean add(OperatelogDetailModel model) {
        return dao.addObject(model.getModuleName() + ".insert", model);
    }

    @Override
    public OperatelogDetailModel getInfoById(String s) {
        OperatelogDetailModel model = null;
        model = (OperatelogDetailModel) dao.queryObject(model.getModuleName() + ".getInfoById", s);
        return model;
    }

    @Override
    public int edit(OperatelogDetailModel model) {
        return dao.updateObject(model.getModuleName() + ".update", model);
    }

    @Override
    public int delete(String ids) {
        String[] id_array = ids.split(",");
        int num = 0;
        for (String id : id_array) {
            dao.deleteObject(new OperatelogDetailModel().getModuleName() + ".delete", id);
            num++;
        }
        return num;
    }

}
